package com.lm.activiti.boot.cases;

import com.google.common.collect.Lists;
import org.junit.Test;

import java.util.Iterator;
import java.util.List;

/**
 * @author lm_jcf
 * @date 2020/3/3 11:27
 */
public class IteratorTest {

    @Test
    public void recoverIterator(){
        List<Integer> list = Lists.newArrayList(0, 1, 2, 3, 6, 4);

        Iterator<Integer> iterator = list.iterator();

        list.remove(4);

        System.out.println(list);

        while (iterator.hasNext()) {
            Integer next = iterator.next();
            System.out.println(next);
            if (next == 3) {
                iterator.remove();
            }
        }

        iterator = list.iterator();
        while (iterator.hasNext()) {
            Integer next = iterator.next();
            System.out.println(next);
        }

    }

    @Test
    public void fail_iterator() {


    }

}
